package com.commerceE.service.impl;

import java.util.List;

import org.springframework.transaction.annotation.Transactional;

import com.commerceE.common.exception.ServiceException;
import com.commerceE.domain.Products;
import com.commerceE.service.ProductService;

public class ProductServiceImpl implements ProductService {
	
//	@Autowired
//	private ProductDao productDao;
//	
//	@Autowired
//	private ProductInstanceDao productInstanceDao;
	
//	@Autowired
//	private ImageDao imageDao;
	
 
	/* (non-Javadoc)
	 * @see com.commerceE.service.ProductService#getAllListOfProduct()
	 */
	public List<Products> getAllListOfProduct() throws ServiceException{
//		try {
//			return productDao.getAllListOfProduct();
//		} catch (DaoException e) {
//			throw new ServiceException(e.getExceptionCode(),e.getExceptionMessage());
//		}
		return  null;
	}
	
 
	/* (non-Javadoc)
	 * @see com.commerceE.service.ProductService#insertProduct(com.commerceE.domain.Product)
	 */
	@Transactional(readOnly = false, rollbackFor = Exception.class)
	public void insertProduct(Products product) throws ServiceException{
//		try {
//			productDao.insertProduct(product);
//		} catch (DaoException e) {
//			throw new ServiceException(e.getExceptionCode(),e.getExceptionMessage());
//		}
	}
	
	
	public Products getProductById(String productId) throws ServiceException{
		Products product = null;
//		try {
//			product = productDao.getProductById(productId);
//			if(product==null){
//				return null;
//			}else{
//				product.setProductionAttributeList(productInstanceDao.getProductAttributesByProductId(productId));
//				product.setProductionOptionList(productInstanceDao.getProductOptionListByProductId(productId));
//				product.setImageEntityList(imageDao.getImageEntityListByInstanceId(productId));
//				List<ProductInstance> productInstanceList = productInstanceDao.getProductInstanceListByProductId(productId);
//				int totleQuantity = 0;
//				for(ProductInstance productInstance:productInstanceList){
//					totleQuantity = totleQuantity+productInstance.getQuantity();
//				}
//				product.setProductInstanceList(productInstanceDao.getProductInstanceListByProductId(productId));
////				product.setTotleQuantity(productInstanceDao.getTotleQuantityOfProduct(productId));
//				product.setTotleQuantity(totleQuantity);
//			}
//		} catch (DaoException e) {
//			throw new ServiceException(e.getExceptionMessage());
//		}
		return product; 
	}

}
